'use strict';

const { Controller } = require('egg');
class StationCotroller extends Controller {
  async create() {
    const data = this.ctx.request.body;
    const response = await this.ctx.service.station.create(data);
    this.ctx.body = response;
  }

  async index() {
    const response = await this.ctx.service.station.getAllStation();
    this.ctx.body = response;
  }

  async update() {
    const id = this.ctx.params.id;
    const data = this.ctx.request.body;
    const response = await this.ctx.service.station.updateStation(id, data);
    this.ctx.body = response;
  }

  async distroy() {
    const id = this.ctx.params.id;
    const response = this.ctx.service.station.deleteStation(id);
    this.ctx.body = response;
  }

  async show() {
    const { id } = this.ctx.params;
    const response = this.ctx.service.station.findById(id);
    this.ctx.body = response;
  }
}

module.exports = StationCotroller;
